package com.sample.rx3.libs.rxjava;

import android.content.Context;

import androidx.annotation.NonNull;

import com.loyal.client.RxConfig;
import com.loyal.rx3.BaseRxSubscriber;
import com.loyal.rx3.RetroManager;

import io.reactivex.rxjava3.core.Observable;

public class RxSystemSubscriber<T> extends BaseRxSubscriber<T> implements SystemServerImpl {

    private SystemServerImpl systemService;
    private final Context context;

    public RxSystemSubscriber(Context context) {
        this.context = context;
    }

    public RxSystemSubscriber(Context context, @NonNull RxConfig config) {
        super(config);
        this.context = context;
    }

    public Context getContext() {
        return context;
    }

    @Override
    public void createServer(RetroManager manager) {
        systemService = manager.createServer(SystemServerImpl.class);
    }

    @Override
    public Observable<String> dictTrans(String token, String typeCode) {
        return systemService.dictTrans(token, typeCode);
    }

    @Override
    public Observable<String> systemParam(String token, String paramKey) {
        return systemService.systemParam(token, paramKey);
    }
}
